/************************************************
Online Appendix G Analyses
***************************************************/

clear
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Data"
use "exp4_cleaned1.dta"
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Online Appendix G"
log using "appendix_g_log.log"
set more off

/*********************************************
Remove VPN and Independents
*********************************************/
keep if pid_2 !=.
keep if IP_Hub_recommend_block == 0

*Leaves 1027 observations


/*********************************************
Cleanings
*********************************************/

label def tr 1 "Baseline" 2 "Party Cue" 3 "Cue w/Insinuation" 4 "Insinuation", replace
label values treat_4 tr

label def lic 1 "Liberal Change" 0 "Conservative Change"
label def stc 0 "Stereotypical Change" 1 "Counter-Stereotyipcal Change" 
label values libchange lic
label values change stc

label def pi 1 "Democrat" 0 "Republican"
label values pid_2 pi

foreach var in inferences special_supporters policy_supporters gain_supporters likeyou_supporters placement {
	summ `var' 
	replace `var' = (`var' - r(min))/(r(max)-r(min))
	}
	
summ inparty
gen in01 = (inparty - r(min))/(r(max)-r(min))

factor *_supporters, pcf
	/*EV = 2.37, proportion = 0.6
	Special and Gain = -0.76 and -0.71; Policy and Like you = 0.79 and 0.81
	*/

rotate
predict factor1
summ factor1
gen motives = (factor1 - r(min))/(r(max)-r(min))


/*********************************************
Table 1 In Text (Table OG1)
*********************************************/
eststo clear
eststo: regress support01 i.treat_4 i.change
eststo: regress argdiff01 i.treat_4 i.change
eststo: regress inferences i.treat_4 i.change
eststo: regress prox01 i.treat_4 i.change
eststo: regress motives i.treat_4 i.change
eststo: regress in01 i.treat_4 i.change

esttab using "table1.rtf", replace onecell se ar2 star(+ 0.1 * 0.05 ** 0.01) ///
		nobaselevels b(2) label ///
		mtitles("Policy Support" "Argument Difference" "Inferences" "Proximity" "Motives" "In-Party Affect") 

/*********************************************
Table OG2: Inferences
*********************************************/
foreach var in growth pers_financial community unemployment poor middle rich {
	summ `var' 
	replace `var' = (`var' - r(min))/(r(max)-r(min))
}

eststo clear
eststo: regress growth i.treat_4 i.change
eststo: regress pers_financial i.treat_4 i.change
eststo: regress community i.treat_4 i.change
eststo: regress unemployment i.treat_4 i.change
eststo: regress poor i.treat_4 i.change
eststo: regress middle i.treat_4 i.change
eststo: regress rich i.treat_4 i.change

esttab using "table_og2.rtf", replace ///
onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("State Growth" "Pers. Finances" "Community" "Unemployment" "Poor" "Middle Class" "Rich") ///
	title("{\b Table OG2:} Individual Inference Items") 

/*********************************************
Table OG3: Motives
*********************************************/

eststo clear
eststo: regress special_supporters  i.treat_4 i.change
eststo: regress gain_supporters i.treat_4 i.change
eststo: regress policy_supporters  i.treat_4 i.change
eststo: regress likeyou_supporters  i.treat_4 i.change

esttab using "table_og3.rtf", replace ///
onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Special Interests" "Personal Gain" "Good Policy" "Ppl Like You") ///
	title("{\b Table OG3:} Individual Motive Items") 
	
	
/*********************************************
Table OG4: Interaction
*********************************************/
eststo clear
eststo: regress support01 i.treat_4##i.change
eststo: regress argdiff01 i.treat_4##i.change
eststo: regress inferences i.treat_4##i.change
eststo: regress prox01 i.treat_4##i.change
eststo: regress motives i.treat_4##i.change
eststo: regress in01 i.treat_4##i.change

esttab using "table_og4.rtf", replace ///
onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Policy Support" "Argument Difference" "Inferences" "Proximity" "Motives" "In-Party Affect") ///
	title("{\b Table OG4:} Interaction Analyses") 

	
foreach var in support01 argdiff01 inferences prox01 motives in01 { 
	regress `var' i.treat_4##i.change
	margins, dydx(treat_4) by(change) saving(`var', replace)
	}
	
	
/*********************************************
Table OG5: Placement
*********************************************/

eststo clear
eststo: regress placement i.treat_4 i.libchange
eststo: regress placement i.libchange if treat_4 == 1

clear
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\\Data"
use "exp3_cleaned.dta"
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Online Appendix G"
set more off

summ placement
replace placement = (placement - r(min))/(r(max)-r(min))
keep if pid_2 == "Democrat" | pid_2 == "Republican"

encode treat_3, gen(tr1)
encode change, gen(tr2)

eststo: regress placement i.tr1 i.tr2
eststo: regress placement i.tr2 if tr1 == 1

esttab using "table_ogX.rtf", replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Sept 2020" "Sept 2020, No Cue" "Exp 3" "Exp 3, No Cue") ///
	title("{\b Table OG5:} Policy Placement") ar2
	
	
log close
